<?php

namespace app\common\model;

use Ramsey\Uuid\Uuid;
use Think\Db;
use think\Model;

/**
 * 维一编号
 */
class Uuids extends Base
{


    public function getDatas()
    {

        $where = $this->_dataWhere();
        $page  = input('get.page');
        $limit = input('get.limit');

        return $this->where($where)->order('id','desc')->page($page,$limit)->select()->toArray();

    }

    public function getDatasCount()
    {
        $where = $this->_dataWhere();

        return $this->where($where)->count();
    }



    public function _dataWhere()
    {

        $where = ' 1 ';

        if (input('get.key/a')) {
            foreach (input('get.key/a') as $k => $v) {
                if (!empty($v)) {
                    switch ($k) {
                    }
                }
            }
        }

        return $where;
    }


    //添加
    public function addCodes($num=0)
    {

        $uuids = [];
        for($i=$num;$i>0;$i--){
            $tmp['uuid'] = Uuid::uuid1();
            $uuids[] = $tmp;
        }

        $res = $this->saveAll($uuids);

        return $res ?: false;
    }

}
